package com.sheng.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class AOPAdvice {
    @Pointcut("execution(* *..UserService*.save(..))")
    public void pt() {
    }

    @Before("pt()")
    public void before(JoinPoint jpt) {
        Object[] args = jpt.getArgs();
        System.out.println("before.....222" + "  " +args[0]);
    }

    @After("pt()")
    public void after() {
        System.out.println("after.....");
    }

    @AfterReturning(value = "pt()", returning = "ret")
    public void AfterReturning(Object ret) {
        System.out.println("AfterReturning....." + ret);
    }
    @Around(value ="pt()")
    public void around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("前置");
        Object proceed = pjp.proceed();
        Object[] args = pjp.getArgs();
        System.out.println("around的"+args[0]);
        System.out.println("后置");
    }
}
